<div class="row-fluid" style="margin-top:20px;">
    <?php echo $this->partial('shopfront/home/left_menu.phtml'); ?>
    <div class="span8" id="home_goods_order">
        <div class="well">
            <h5><?php echo $this->translate('我的优惠券'); ?></h5>
            <ul class="nav nav-tabs">
                <li <?php if ($this->state == 'all') echo 'class="active"'; ?>><a href="<?php echo $this->url('frontcoupon/default', array('action'=>'index'), array('query'=>array('state'=>'all'))); ?>"><?php echo $this->translate('全部优惠券'); ?><?php if ($this->coupon_num['all']>0) { ?><span class="badge"><?php echo $this->coupon_num['all']; ?></span><?php } ?></a></li>
                <li <?php if ($this->state == '0') echo 'class="active"'; ?>><a href="<?php echo $this->url('frontcoupon/default', array('action'=>'index'), array('query'=>array('state'=>'0'))); ?>"><?php echo $this->translate('未生效优惠券'); ?><?php if ($this->coupon_num['0']>0) { ?><span class="badge label-inverse"><?php echo $this->coupon_num['0']; ?></span><?php } ?></a></li>
                <li <?php if ($this->state == '1') echo 'class="active"'; ?>><a href="<?php echo $this->url('frontcoupon/default', array('action'=>'index'), array('query'=>array('state'=>'1'))); ?>"><?php echo $this->translate('可用优惠券'); ?><?php if ($this->coupon_num['1']>0) { ?><span class="badge badge-success"><?php echo $this->coupon_num['1']; ?></span><?php } ?></a></li>
                <li <?php if ($this->state == '2') echo 'class="active"'; ?>><a href="<?php echo $this->url('frontcoupon/default', array('action'=>'index'), array('query'=>array('state'=>'2'))); ?>"><?php echo $this->translate('已用优惠券'); ?><?php if ($this->coupon_num['2']>0) { ?><span class="badge label-info"><?php echo $this->coupon_num['2']; ?></span><?php } ?></a></li>
                <li <?php if ($this->state == '3') echo 'class="active"'; ?>><a href="<?php echo $this->url('frontcoupon/default', array('action'=>'index'), array('query'=>array('state'=>'3'))); ?>"><?php echo $this->translate('过期优惠券'); ?><?php if ($this->coupon_num['3']>0) { ?><span class="badge label-important"><?php echo $this->coupon_num['3']; ?></span><?php } ?></a></li>
            </ul>
            <?php if ($this->user_coupon_list) { ?>
                <table class="table table-bordered">
                    <thead>
                    <tr class="home-user-tr">
                        <th width="15%"><?php echo $this->translate('优惠券名称'); ?></th>
                        <th width="25%"><?php echo $this->translate('优惠券描述'); ?></th>
                        <th width="10%"><?php echo $this->translate('优惠券状态'); ?></th>
                        <th width="20%"><?php echo $this->translate('有效期'); ?></th>
                        <th width="20%"><?php echo $this->translate('使用优惠券的订单号'); ?></th>
                    </tr>
                    </thead>
                    <?php foreach ($this->user_coupon_list as $coupon_value) {
                            ?>
                            <tr>
                                <td><?php echo $this->escapeHtml($coupon_value['coupon_name']); ?></td>
                                <td><?php echo $this->escapeHtml($coupon_value['coupon_info']); ?></td>
                                <td>
                                    <?php
                                        $couponStateArray = array(0=>$this->translate('未生效优惠券'), 1=>$this->translate('可用优惠券'), 2=>$this->translate('已用优惠券'), 3=>$this->translate('过期优惠券'));
                                        echo $couponStateArray[$coupon_value['coupon_use_state']];
                                    ?>
                                </td>
                                <td>
                                    <?php
                                    $start_time = empty($coupon_value['coupon_start_use_time']) ? '' : date("Y-m-d H:i", $coupon_value['coupon_start_use_time']);
                                    $end_time   = empty($coupon_value['coupon_expire_time']) ? '' : date("Y-m-d H:i", $coupon_value['coupon_expire_time']);
                                    if($start_time == '' and $end_time == '') {
                                        $start_and_end_time = $this->translate('长期有效');
                                    } elseif ($end_time != '' and time() > $coupon_value['coupon_expire_time']) {
                                        $start_and_end_time = '<font color="#FF0000">' . $this->translate('已经过期') . '</font>';
                                    } else {
                                        $start_and_end_time = (empty($start_time) ? $this->translate('无') : $start_time) . ' / ' . (empty($end_time) ? $this->translate('无') : $end_time);
                                    }

                                    echo $start_and_end_time; ?>
                                </td>
                                <td><?php echo $coupon_value['used_order_sn']; ?></td>
                            </tr>
                            <?php } ?>
                    <tr>
                        <td colspan="8">
                            <?php echo ( count($this->user_coupon_list) > 0 ) ? $this->paginationControl($this->user_coupon_list, 'Sliding', 'site/dbpage',array('page_url'=>$this->url('frontcoupon/default/coupon_page', array('action'=>'index', 'id'=>0), array('query'=>array('state'=>$this->state))))) : ""; ?>
                        </td>
                    </tr>
                </table>
            <?php } else { echo '<p>' . $this->translate('暂无优惠券信息！') . '</p>'; } ?>
        </div>
    </div>
</div>